﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace CoreModule.Converters
{
    /// <summary>
    /// sbp 压力状态转颜色。
    /// </summary>
    public class SbpPressureStatusToColorConverter : IValueConverter
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Color myColor = (Color)ColorConverter.ConvertFromString("#EDD149");
            SolidColorBrush myBrush = new SolidColorBrush(myColor);
            if (value == null)
            {
                return myBrush;
            }
            PressureStatus status = (PressureStatus)value;
            switch (status)
            {
                case PressureStatus.None:
                    myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureStatus.High1:
                    myColor = (Color)ColorConverter.ConvertFromString("#EB1C2A");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureStatus.High2:
                    myColor = (Color)ColorConverter.ConvertFromString("#EB1C2A");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureStatus.High3:
                    myColor = (Color)ColorConverter.ConvertFromString("#EB1C2A");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureStatus.Low:
                    myColor = (Color)ColorConverter.ConvertFromString("#F58B00");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureStatus.Normal:
                    myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                default:
                    return myBrush;
            }
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
